import { object_Inf } from "@/utils/typings/index.type";
import { selectTableCloumn_Inf, selectTableTypeEnum } from "../index.type";
import i18n from "@/international/i18n";

/*
 * @Descripttion:选择对象列表工具类
 * @LastEditors: xzh
 * @LastEditTime: 2023-09-15 21:33:41
 */
export default class SelectTableUtils {
  /**
   * @Author: xzh
   * @Descripttion:语言配置
   * @Param:
   */
  static t: any = i18n().global.t;
  /**
   * @Author: xzh
   * @Descripttion: 表格列表映射
   * @Param:
   */
  static tableColumnMap = {
    //设备
    [selectTableTypeEnum.equip]: [
      {
        field: "code",
        //t('page.equipManageArr.equipArchivesArr.code')
        title: "page.equipManageArr.equipArchivesArr.code",
      },
      {
        field: "name",
        //t('page.equipManageArr.equipArchivesArr.name')
        title: "page.equipManageArr.equipArchivesArr.name",
      },
      {
        field: "specification",
        //t('page.equipManageArr.equipArchivesArr.specification')
        title: "page.equipManageArr.equipArchivesArr.specification",
      },
      {
        field: "equipType",
        //t('page.equipManageArr.equipType')
        title: "page.equipManageArr.equipType",
        formatField: "typeName",
      },
      {
        field: "position",
        //t('page.systemManageArr.position')
        title: "page.systemManageArr.position",
        formatField: "positionName",
      },
      {
        field: "equipState",
        //t('page.equipManageArr.equipState')
        title: "page.equipManageArr.equipState",
        formatField: "statusName",
      },
    ],
    //模具
    [selectTableTypeEnum.mold]: [
      {
        field: "code",
        //t('page.moldManageArr.moldArchivesArr.code')
        title: "page.moldManageArr.moldArchivesArr.code",
      },
      {
        field: "name",
        //t('page.moldManageArr.moldArchivesArr.name')
        title: "page.moldManageArr.moldArchivesArr.name",
      },
      {
        field: "specification",
        //t('page.moldManageArr.moldArchivesArr.specification')
        title: "page.moldManageArr.moldArchivesArr.specification",
      },
      {
        field: "moldType",
        //t('page.moldManageArr.moldType')
        title: "page.moldManageArr.moldType",
        formatField: "typeName",
      },
      {
        field: "position",
        //t('page.systemManageArr.position')
        title: "page.systemManageArr.position",
        formatField: "positionName",
      },
      {
        field: "moldState",
        //t('page.moldManageArr.moldState')
        title: "page.moldManageArr.moldState",
        formatField: "statusName",
      },
    ],
    //设备保养项目
    [selectTableTypeEnum.equipUpkeepItem]: [
      {
        field: "code",
        //t('page.equipUpkeepArr.upkeepItemArr.code')
        title: "page.equipUpkeepArr.upkeepItemArr.code",
        width: 200,
      },
      {
        field: "name",
        //t('page.equipUpkeepArr.upkeepItemArr.name')
        title: "page.equipUpkeepArr.upkeepItemArr.name",
        width: 200,
      },
      {
        field: "maintenancePart",
        //t('page.equipUpkeepArr.upkeepItemArr.maintenancePart')
        title: "page.equipUpkeepArr.upkeepItemArr.maintenancePart",
        width: 100,
      },
      {
        field: "maintenanceLevel",
        //t('page.equipUpkeepArr.upkeepItemArr.maintenanceLevel')
        title: "page.equipUpkeepArr.upkeepItemArr.maintenanceLevel",
        width: 100,
        formatField: "maintenanceLevelName",
      },
      {
        field: "maintenanceDemand",
        //t('page.equipUpkeepArr.upkeepItemArr.maintenanceDemand')
        title: "page.equipUpkeepArr.upkeepItemArr.maintenanceDemand",
      },
      {
        field: "remark",
        //t('common.remark')
        title: "common.remark",
      },
    ],
    //模具保养项目
    [selectTableTypeEnum.moldUpkeepItem]: [
      {
        field: "code",
        //t('page.moldUpkeepArr.upkeepItemArr.code')
        title: "page.moldUpkeepArr.upkeepItemArr.code",
        width: 200,
      },
      {
        field: "name",
        //t('page.moldUpkeepArr.upkeepItemArr.name')
        title: "page.moldUpkeepArr.upkeepItemArr.name",
        width: 200,
      },
      {
        field: "maintenancePart",
        //t('page.moldUpkeepArr.upkeepItemArr.maintenancePart')
        title: "page.moldUpkeepArr.upkeepItemArr.maintenancePart",
        width: 100,
      },
      {
        field: "maintenanceLevel",
        //t('page.moldUpkeepArr.upkeepItemArr.maintenanceLevel')
        title: "page.moldUpkeepArr.upkeepItemArr.maintenanceLevel",
        width: 100,
        formatField: "maintenanceLevelName",
      },
      {
        field: "maintenanceDemand",
        //t('page.moldUpkeepArr.upkeepItemArr.maintenanceDemand')
        title: "page.moldUpkeepArr.upkeepItemArr.maintenanceDemand",
      },
      {
        field: "remark",
        //t('common.remark')
        title: "common.remark",
      },
    ],
  };
  /**
   * @Author: xzh
   * @Descripttion: 格式化列
   * @Param:
   * @param {selectTableTypeEnum} selectTableType 选择对象类型
   * @param {object_Inf} row 行
   * @param {selectTableCloumn_Inf} colunmInfo 列信息
   */
  static formatColumn(
    selectTableType: selectTableTypeEnum | string,
    row: object_Inf,
    colunmInfo: selectTableCloumn_Inf
  ) {
    let { cusFormat, field, formatField }: object_Inf = colunmInfo;
    //是否自定义格式化
    if (!!cusFormat) {
      switch (selectTableType) {
        case selectTableTypeEnum.equipUpkeepItem:
          //设备
          break;
      }
    } else {
      return row?.extJson[formatField] || row[field];
    }
  }
}
